﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using HWmanagementDB;

namespace HWmanagementServer
{
    [DataContract]
    public class HomeworkModel
    {
        [DataMember]
        public int id;
        [DataMember]
        public int courseid;
        [DataMember]
        public string userid;
        [DataMember]
        public int fileid;
        [DataMember]
        public string title;
        [DataMember]
        public string shortdesc;
        [DataMember]
        public DateTime deadline;

        public static HOMEWORK toDBTable(HomeworkModel hwm)
        {
            return new HOMEWORK() { ID = hwm.id, COURSEID = hwm.courseid, USERID = hwm.userid, FILEID = hwm.fileid, TITLE = hwm.title, SHORT = hwm.shortdesc, DEADLINE = hwm.deadline};
        }

        public static HomeworkModel fromDBTable(HOMEWORK h)
        {
            return new HomeworkModel() { id = h.ID, courseid = h.COURSEID, userid = h.USERID, fileid = (int)h.FILEID, title = h.TITLE, shortdesc = h.SHORT, deadline = h.DEADLINE };
        }
    }
}
